#include <iostream>
#include <thread>
#include <string>
#include <sstream>

using namespace std;

void func(int &n,string &str){
    n = 10;
    str = "ame";
    this_thread::sleep_for(chrono::seconds(3));
    cout << "sub thread:" << this_thread::get_id() << endl;
    std::stringstream sin;
    sin << this_thread::get_id();
    string id = sin.str();
    cout << id << endl;

}

int main(){
    cout << "main:" << this_thread::get_id() << endl;
    int n = 0;string str = "china";
    thread t(func,std::ref(n),std::ref(str));
    //t.detach();
    if(t.joinable())
        t.join();
    cout << n << " " << str << endl;
    cout << "over" << endl;
    return 0;
}

#if 0
int main()
{
    cout << "main thread:" << this_thread::get_id() << endl;
    thread th(func);
    th.join();
    cout << "over" << endl;
    return 0;
}
#endif
